﻿using System.Collections.Generic;
using LiuQiuRong.Chat.Businesses.Users;
using LiuQiuRong.Chat.Businesses.Users.Dtos;
using LiuQiuRong.Chat.Utilities.Enum;
using Microsoft.AspNetCore.Mvc.RazorPages;

namespace LiuQiuRong.Chat.Web.Pages
{
    public class IndexModel : PageModel
    {
        private readonly IUserServices _userServices;
        public IndexModel(IUserServices userServices)
        {
            _userServices = userServices;
        }

        public UserLoginDto LoginUser { get; set; }

        public string yyyyMMddHHmmss = DateTimeFormat.yyyyMMddHHmmss;

        public List<UserLoginDto> OnlineUsers { get; set; }

        public void OnGet()
        {
            LoginUser =  _userServices.GetCurrentUser(User);
            OnlineUsers = _userServices.GetOnlineUsers();
            if (OnlineUsers == null)
                Response.Redirect("/login");
        }
    }
}
